import React from 'react'
// ===================================================================== Declare
const { $fn, $Lazy } = window
// ===================================================================== Lazy
const Table = $Lazy.load(()=>import('@antd/table'))
const Page 	= $Lazy.load(()=>import('#tp/page/page-container'))
// ===================================================================== component
class Index extends React.Component{
	state = {
		data:[],
		pag: {},
		selectedKeys:[],
	}
	
	model = {}
	
	componentDidMount(){
		const { code } = $fn.query()
		this.query = { code }
		
		this.fetch()
	}

	// paging
	fetch = () => $fn.fetch.call(this,'bs-contract/getContactRenew')
	
	// 表单
	cols = [
		{ title: '合同编号',		dataIndex: 'code', 					width:150 },
		{ title: '合同名称', 	dataIndex: 'name', 					width:150 },
		{ title: '客户名称', 	dataIndex: 'hosp_name', 			width:200 },
		{ title: '生效时间', 	dataIndex: 'sign_at', 				...$fn.table.time },
		{ title: '到期时间',		dataIndex: 'contract_validity', 	...$fn.table.time },
		{ title: '折扣率', 		dataIndex: 'discount_rate', 		...$fn.table.num },
		{ title: '操作人', 		dataIndex: 'real_name', 		...$fn.table.name },
	]
	
	// 操作按钮
	controls = () => {
		const { pagingLoading } = this.state
		return [
			{ label:'返回', ghost:true, loading:pagingLoading, onClick:()=> $fn.back(this) },
		]
	}
	
	render(){
		const { data, pagingLoading, pag } = this.state
		return (
			<>
				<Page title='合同签订记录' controls={this.controls()}>
					<div className='h10'></div>
					{/* 表格 */}
					<Table
						type 			= 'checked'
						cols			= { this.cols }
						data 			= { data }
						loading 		= { pagingLoading }
						pag				= { pag }
						onChange		= { (current, pageSize) => $fn.pageChange.call(this,{current, pageSize}) }
					/>
				</Page>
			</>
		)
	}
}

export default Index